<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('福利缴纳变动添加')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>

</head>
<style>
    .select-list li p {

        margin: 4px 0px 5px 0px;
    !important;
    }

    .fixed-table-container .bs-checkbox .th-inner {
        padding: 8px 8px !important;
    }
</style>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>工号：</p>
                            <input type="text" name="badge"/>
                        </li>
                        <li>
                            <p>姓名：</p>
                            <input type="text" name="name"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>


        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="aa()" shiro:hasPermission="system:benefitbase:add">
                <i class="fa fa-plus"></i> 添加员工
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: bootstrap-table-editable-js"/>

<script th:inline="javascript">
    var prefix = ctx + 'welfare/welfareInfo';
    $(function () {
        queryData();
    })

    function queryData() {
        var columns = [];
        var checkbox = {checkbox: true};
        var Badge = {field: 'badge', title: '员工编号'};
        var Name = {field: 'name', title: '姓名'};
        var CompId = {field: '公司名称', title: '公司名称'};
        var DepId = {field: '部门名称', title: '部门名称'};
        var JobId = {field: '工作岗位', title: '工作岗位'};
        var joinDate = {field: '入职时间', title: '入职时间'};
        var EmpStatus = {field: '员工状态', title: '员工状态'};
        var JobStatus = {field: '在岗状态', title: '在岗状态'};
        var BENEFITSTATUS = {field: '缴纳状态', title: '缴纳状态'};
        var BENEFITCITY = {field: '社保缴纳地区', title: '社保缴纳地区'};
        var ACCUCITY = {field: '公积金缴纳地区', title: '公积金缴纳地区'};
        var ACCUACCOUNT = {field: '公积金账户', title: '公积金账户'};
        var BENEACCOUNT = {field: '社保账户', title: '社保账户'};
        var EffectDate = {field: '开始缴纳日期', title: '开始缴纳日期'};
        var sbxValue = {field: '社保基数', title: '社保基数'};
        var gjjxValue = {field: '公积金基数', title: '公积金基数'};
        columns.push(checkbox, Badge, Name, CompId, DepId, JobId, joinDate, EmpStatus, JobStatus, BENEFITSTATUS, BENEFITCITY, ACCUCITY, ACCUACCOUNT, BENEACCOUNT, EffectDate, sbxValue, gjjxValue);
        var options = {
            code: "PEID",
            uniqueId: "PEID",
            url: prefix + '/list',
            modalName: "添加员工",
            height: $(window).height() - 110,
            columns: columns
        };
        $.table.init(options);
    }

    function aa() {
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        if (row.length == 0) {
            $.modal.alertWarning("请选择数据!");
            return;
        }
        var allPEID = "";
        for (var i = 0; i < row.length; i++) {
            if (i == row.length - 1) {
                allPEID += row[i].PEID
            } else {
                allPEID += row[i].PEID + ","

            }
        }


        $.ajax({
            async: false,
            url: ctx + "welfare/welfareChange/addChangeProcedure",
            data: {
                allPeid: allPEID
            },
            type: "post",
            dataType: "json",
            success: function (data) {

                //todo 这里需要判断data返回值
                if (data.code == 0) {
                    $.modal.alertWarning("添加成功！");
                    $.modal.close();
                    $.modal.reload();
                } else if (data.code == 500) {
                    $.modal.alertWarning("服务繁忙");
                } else {
                    $.modal.alertWarning(data.message);
                }

            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });


    }

    function submitHandler() {
        aa();

    }


</script>
</body>
</html>